<template>
    <div>
      <el-dialog :visible.sync="modals" width="540px" :title="titleFrom" :close-on-click-modal="false">
        <el-form ref="formValidate" :model="formValidate" label-width="80px" @submit.native.prevent>
          <el-row :gutter="24">
            <el-col v-bind="grid">
              <el-form-item label="分类名称：">
                <el-input v-model="formValidate.name" placeholder="请输入分类名称"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button v-db-click @click="handleReset">取 消</el-button>
          <el-button type="primary" v-db-click @click="handleSubmit('formValidate')" :disabled="valids">提 交</el-button>
        </span>
      </el-dialog>
    </div>
  </template>
  
  <script>
  import { setSkillCategory } from '@/api/classification';
  
  export default {
    name: 'category',
    props: {
      formValidate: {
        type: Object,
        default: null,
      },
      titleFrom: {
        type: String,
        default: '',
      },
    },
    data() {
      return {
        grid: {
          xl: 24,
          lg: 24,
          md: 24,
          sm: 24,
          xs: 24,
        },
        modals: false,
        FromData: [],
        valids: false,
      };
    },
    watch: {},
    computed: {},
    methods: {
      handleSubmit(name) {
        let data = {
          url: this.formValidate.id ? `classification/skillCategory/${this.formValidate.id}` : 'classification/skillCategory',
          method: this.formValidate.id ? 'put' : 'post',
          datas: this.formValidate,
        };
  
        if (!this.formValidate.name) {
          return this.$message.warning('请填写技能分类名称');
        }
  
        this.valids = true;
        setSkillCategory(data)
          .then(async (res) => {
            this.$message.success(res.msg);
            this.modals = false;
            this.$emit('changeMenu', this.formValidate);
          })
          .catch((res) => {
            this.valids = false;
            this.$message.error(res.msg);
          });
      },
      handleReset() {
        this.modals = false;
        this.$refs['formValidate'].resetFields();
        this.$emit('clearFrom');
      },
    },
  };
  </script>
  
  <style scoped>
  .trees-coadd {
    width: 100%;
    height: 500px;
    border-radius: 4px;
    overflow: hidden;
  }
  
  .scollhide {
    width: 100%;
    height: 100%;
    overflow: auto;
    margin-left: 18px;
    padding: 10px 0 10px 0;
    box-sizing: border-box;
  }
  
  .content {
    font-size: 12px;
  }
  
  .time {
    font-size: 12px;
    color: #2d8cf0;
  }
  
  .icons-item {
    float: left;
    margin: 6px 6px 6px 0;
    width: 53px;
    text-align: center;
    list-style: none;
    cursor: pointer;
    height: 50px;
    color: #5c6b77;
    transition: all 0.2s ease;
    position: relative;
    padding-top: 10px;
  }
  
  .icons-item .f-s-24 {
    font-size: 24px;
  }
  
  .search-rule {
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: #f2f2f2;
  }
  
  .rule {
    display: flex;
    flex-wrap: wrap;
    max-height: 700px;
    overflow: scroll;
  }
  
  /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
  .rule::-webkit-scrollbar {
    width: 10px;
    height: 10px;
    background-color: #f5f5f5;
  }
  
  /*定义滚动条轨道 内阴影+圆角*/
  .rule::-webkit-scrollbar-track {
    border-radius: 4px;
    background-color: #f5f5f5;
  }
  
  /*定义滑块 内阴影+圆角*/
  .rule::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background-color: #555;
  }
  
  .rule-list {
    background-color: #f8f5f5;
    width: 32%;
    margin: 5px;
    border-radius: 3px;
    padding: 10px;
    color: #333;
    cursor: pointer;
    transition: all 0.1s;
  }
  
  .rule-list:hover {
    background-color: #c5d1dd;
  }
  
  .rule-list div {
    white-space: nowrap;
  }
  
  .select-rule {
    background-color: #c5d1dd;
  }
  
  .add {
    display: flex;
    align-items: center;
  }
  
  .df {
    display: flex;
    justify-content: center;
  }
  </style>
  